<?php
use yii\helpers\Html;
use yii\helpers\HtmlPurifier;
use yii\widgets\LinkPager;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
$this->title = '软件展示';
?>

<div class="container">
    <div class="row">
        <?php echo $this->render('_leftnav'); ?>

        <div class="col-md-10">
            <div class="page-header clearfix">
                <h1 class="pull-left">软件展示</h1>
                <div class="pull-right"><a class="btn btn-success btn-sm" href="index.php?r=download/uploadsoft">添加软件</a></div>
            </div>
      
            <?php
            $form = ActiveForm::begin([
            'action' => ['download/softdel'],
            'method'=>'post',
            'options' => [
                'enctype' => 'multipart/form-data',
                'class'=>'form-horizontal',
                ]	
            ]);	
            ?>

        <div id="aticle-table-container">

            <table class="table table-hover table-striped" id="article-table">
                <thead>
                    <tr>
                        <th width="10%">ID</th>
                        <th width="20%">软件名称</th>
                        
                        <th width="15%">下载次数</th>
                        
                        <th width="18%">更新时间</th>
                        <th width="15%">软件大小</th>
                        <th width="10%">软件状态</th>
                        
                        <th width="15%">操作</th>
                    </tr>
                </thead>
                <tbody>	
                <?php foreach($lists as $key=>$val):?>
                <tr id="article-<?=Html::encode($val['soft_id'])?>" align='left'>
                    <td>
                        <input value="<?=Html::encode($val['soft_id'])?>" name='delid[]' data-role="batch-item" type="checkbox">
                    </td>
                    <td>
                        <span class="text-muted">
                            <a href="<?=Url::toRoute(['download/updatesoft', 'id' =>$val['soft_id']]);?>" target="_self"><?=Html::encode($val['soft_name']);
                            ?> </a>
                        </span>
                    </td>
                    <td>
                        <span class="text-muted">
                            <a href="#" target="_blank"><?=Html::encode($val['soft_down_count'])?> 次</a>
                        </span>
                    </td>
                    <td><?=date('Y-m-d H:i:s',$val['soft_updtime']);?></td>
                    <td><?=$val['soft_size']?> /M</td>

                    <td>
                        <?php if($val['soft_status']==1){?>
                        <span class="text-success">允许</span>
                        <?php }else{ ?>
                        <span class="text-success">不允许</span>
                        <?php } ?>
                    </td>

                    <td>
                        <div class="btn-group">
                            <a href="<?=Url::toRoute(['download/updatesoft', 'id' =>$val['soft_id']]);?>" class="btn btn-default btn-sm">编辑</a>
                            <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                            <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="javascript:" data-role="unpublish-item" data-url="/admin/article/12/unpublish">取消发布</a></li>
                                <li><a href="javascript:" data-role="trash-item" data-url="/admin/article/12/trash">移至回收站</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                <?php endforeach; ?>	
                </tbody>
            </table>
            <div>
                <label class="checkbox-inline"><input data-role="batch-select" type="checkbox" onclick='quan(this)'> 全选</label>
                <input class="btn btn-default btn-sm mlm" type='submit' onclick='return delinfo()' value='删除' />
                
                <div style=' margin-left:38%;'>
                    <?= LinkPager::widget(['pagination' => $pages]); ?>
                </div>
            </div>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>
<script type="text/javascript">
 function delinfo(){
    if(confirm('您确定要删除吗？')){   	  	  	 
        return true;
    }else{
        return false;
    }
 }
 
 function quan(th) {
         var arr = document.getElementsByName('delid[]');
         for(var i=0; i<arr.length; i++){
            arr[i].checked= th.checked;
         }
    }
</script>